package util;

import java.io.*;
import java.util.HashSet;

public class WordDic {
	HashSet<String> wordSet;
	
	public static WordDic stopWordDic;
	static {
		stopWordDic = new WordDic("essential\\myStopWords.txt");
	}
	
	public WordDic(String filePath) {
		loadDictionary(filePath);
	}
	
	private void loadDictionary(String filePath) {
		wordSet = new HashSet<String>();
		try {
			BufferedReader fileBr = new BufferedReader(new FileReader(filePath));
			String word;
			while((word = fileBr.readLine()) != null) {
				wordSet.add(word);
			}
			fileBr.close();
			
		} catch(IOException ioEx) {
			System.err.println(ioEx.getMessage());
			ioEx.printStackTrace();
		}
	}
	
	public boolean hasWord(String word) {
		if(wordSet.contains(word))
			return true;
		return false;
	}
	
	public HashSet<String> getWordSet() {
		return wordSet;
	}
}
